home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: Noise.ieb 1.1, IE Arexx script ** Image Engineer Batch Processing script ** Copyright © by Patrik M Nydensten ** 25/1 1997 Stockholm/Sweden ** ** Add noise to image. */ options results signal on error parse arg input command input = upper(strip(input)) address 'IMAGEENGINEER' select /* Required batch script commands */ when input = 'INFO' then return get_info() when input = 'CONFIG' then return get_config(command) when input = 'PROCESS' then return process_image(command) otherwise do 'REQUEST' '"Failure in call to batch script!"' '" Quit "' return '<ERROR>' end end exit 0 /* Required "Get_info" procedure ------------------------------------ */ /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files */ get_info: back = 'OK' return back /* Required "Get_config" procedure ---------------------------------- */ get_config: parse arg '"'command'"' Affect=50 ; Addit=50 if command ~= '' then parse var command '#'CalcType '#'AB '#'BB '#'CB Affect '#'Noise Addit '#'Dist 'IE_TO_FRONT' form = 'FORM "Noise" " OK | Cancel "' if command = '' then form = form||' CYCLE,"Components:","Intensity, Hue, Saturation|Red, Green, Blue",0', ' CHECKBOX,"Intensity / Red",1', ' CHECKBOX,"Hue / Green",0', ' CHECKBOX,"Saturation / Blue",0' form = form||' INTEGER,"Noise (%)",0,100,'Affect',SLIDER' if command = '' then form = form||' CYCLE,"Noise type:","Random|Additive",0', ' CYCLE,"Additive distribution:","Simple|Gaussian",0' form = form||' INTEGER,"Additive amount",0,100,'Addit',SLIDER' if command = '' then do form parse var result ok CalcType AB BB CB Affect Noise Dist Addit if ok = 0 then return '<ERROR>' end else do form parse var result ok Affect Addit if ok = 0 then return '<ERROR>' CalcType = 'none' AB='none';BB='none';CB='none' Noise = 'none' Dist = 'none' end if (AB=0&BB=0&CB=0) then return '<ERROR>' back = '#'CalcType '#'AB '#'BB '#'CB Affect '#'Noise Addit '#'Dist return back /* Required "Process_image" procedure ------------------------------- */ process_image: parse arg '"'src_image'"' '"'dst_image'"' '"'options'"' parse var options '#'CalcType '#'AB '#'BB '#'CB Affect '#'Noise Addit '#'Dist 'OPEN' '"'src_image'"' '24' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "' return '<ERROR>' end else LoadImage = result if CalcType = 0 then do Calc = '' if AB = 1 then Calc = 'INTENSITY' if BB = 1 then Calc = 'HUE' if CB = 1 then Calc = 'SATURATION' end else do Calc = '' if AB = 1 then Calc = 'RED' if BB = 1 then Calc = 'GREEN' if CB = 1 then Calc = 'BLUE' end if Dist = 0 then Dist = 'SIMPLE' else Dist = 'GAUSSIAN' if Noise = 0 then 'NOISE' LoadImage Affect strip(Calc) 'RANDOM' else 'NOISE' LoadImage Affect strip(Calc) 'ADDITIVE' Addit Dist OutputImage = result 'CLOSE' LoadImage if getclip('cfg_save_frmt')='' then setclip('cfg_save_frmt','ILBM CmpByteRun1') 'SAVE_DATA' OutputImage '"'dst_image'"' '"'getclip('cfg_save_frmt')'"' if (RC ~= 0) then do 'IE_TO_FRONT' 'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "' return '<ERROR>' end 'CLOSE' OutputImage back = 'OK' return back /* Internal procedures ---------------------------------------------- */ /*******************************************************************/ /* This is where control goes when an error code is returned by IE */ /* It puts up a message saying what happened and on which line */ /*******************************************************************/ error: if RC=5 then do IE_TO_FRONT LAST_ERROR 'REQUEST "'||RESULT||'"' end else do IE_TO_FRONT LAST_ERROR 'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!' end return '<ERROR>'